package pdd;


import java.util.Scanner;

public class T2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int len = n;
        int[] array = new int[n];
        int index = 0;
        while (n>0) {
            n--;
            array[index++] = sc.nextInt();
        }
        long result = 0;
        long resultTemp = 0;
        for(int i=0; i<len; i++) {
            resultTemp = 0;
            for (int j=0; j<len; j++) {
                if (i==j) {
                    resultTemp = -resultTemp;
                }
                resultTemp += array[j];
                if (Math.abs(resultTemp) > Math.abs(result)) {
                    result = Math.abs(resultTemp);
                }
            }
        }
        System.out.println(result);
    }
}
